package com.lawyer.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.plugins.Page;
import com.lawyer.common.result.Result;
import com.lawyer.common.result.ResultFactory;
import com.lawyer.constant.Status;
import com.lawyer.model.SysUser;
import com.lawyer.mapper.SysUserMapper;
import com.lawyer.service.SysUserService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 * @author wzq
 * @since 2018-07-16
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
    @Autowired
    SysUserMapper sysUserMapper;
    @Override
    public Result getSysUserList(Page<SysUser> page, String name) {
        JSONObject jsonObject = new JSONObject();
        try{
            List<SysUser> list = sysUserMapper.getSysUserList(page,name);
            page.setRecords(list);
            jsonObject.put("page",page);
        }catch(Exception e){
            return ResultFactory.result(Status.ADD_FAIL,e.getLocalizedMessage());
        }
        return ResultFactory.successData(jsonObject);
    }
}
